package com.starleague.battletech.game.jpa.appengine;

import java.util.Map;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;

import com.starleague.battletech.game.IMutableBattletechTeam;
import com.starleague.battletech.game.dto.IBattletechTeamDto;
import com.starleague.game.jpa.appengine.AbstractTeamGae;

@Entity(name = "BATTLETECH_TEAM")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class BattletechTeamGae
        extends AbstractTeamGae
        implements IMutableBattletechTeam, IBattletechTeamDto
{
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private BattletechGameGae game;

    @Basic(optional = false)
    @Column(nullable = false)
    private int initiativeRoll;

    @Basic(optional = false)
    @Column(nullable = false)
    int unitsToMove;

    BattletechTeamGae(BattletechGameGae game,
                      String name)
    {
        super(name);
        this.game = game;
    }

    protected BattletechTeamGae()
    {
        //
    }

    @Override
    public BattletechGameGae getGame()
    {
        return this.game;
    }

    @Override
    public int getInitiativeRoll()
    {
        return this.initiativeRoll;
    }

    @Override
    public void setInitiativeRoll(int initiativeRoll)
    {
        this.initiativeRoll = initiativeRoll;
    }

    @Override
    public int getUnitsToMove()
    {
        return this.unitsToMove;
    }

    @Override
    public void setUnitsToMove(int unitsToMove)
    {
        this.unitsToMove = unitsToMove;
    }

    @Override
    public Map<String, Object> infoProperties()
    {
        Map<String, Object> infoPropertyMap = super.infoProperties();
        infoPropertyMap.put("initiativeRoll", this.initiativeRoll);
        infoPropertyMap.put("unitsToMove", this.unitsToMove);
        return infoPropertyMap;
    }
}
